﻿#ifndef CCOMMUNICATION_H
#define CCOMMUNICATION_H

#include <QString>
extern unsigned char g_com_buffer[256];
extern unsigned char g_com_size;

const unsigned char remaining_times[13]             = {0x01,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char breath_mode_I[13]               = {0x01,0xff,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char breath_mode_II[13]              = {0x01,0xff,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char await_status[13]                = {0x01,0xff,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_sno_offline[13]             = {0x01,0xff,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_sno_offline_stop[13]        = {0x01,0xff,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_FnNo_mode_I[13]             = {0x01,0xff,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_FnNo_mode_II[13]            = {0x01,0xff,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_FnNo_mode_stop[13]          = {0x01,0xff,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_CaNo_mode_I[13]             = {0x01,0xff,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_CaNo_mode_II[13]            = {0x01,0xff,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_CaNo_mode_stop[13]          = {0x01,0xff,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_pressure_calibration[13]    = {0x01,0xff,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_self_calibration[13]        = {0x01,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char cmd_zero_gas_calibration[13]    = {0x01,0xff,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};


//SerialCMD((unsigned char*),sizeof());
class CCommunication
{
public:
    CCommunication();

    static unsigned short do_crc(unsigned char* data, int length);
    static QString toHexStr(QByteArray data, int len = 0);
};

#endif // CCOMMUNICATION_H
